#----------------------------
# Name: Ryan Dauphinais
# Project: Madlibs.py
# Period: 2
# Start Date: 9/17/2013
# Last Revision Date: 9/17/2013
# Version: 1.0.0
#----------------------------

swearFilter = ["dumb",
               "stupid",
               "retard",
               "shit",
               "fuck",
               "dick",
               "cock",
               "asshole",
               "bitch",
               "hell",
               "motherfucker",]
           

def displayStartScreen():
    print "Madlibs"
    raw_input("Press Enter to Continue")
    
def displayEndScreen():
    print "Goodbye"
    raw_input("Press Enter to Exit")

def getMenuOption(maxOption):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter Number or Q> ")
        option = option.upper()
        for num in range(1, maxOption+1):
            if option == str(num):
                goodOption = True
        if option == 'Q':
            goodOption = True
        if not goodOption:
            print "Please pick a valid option!"
    return option
        
def menu(options):
    print "------Please Select a Story------"
    print " [1] The End of the Day"
    print " [2] My New Pet"
    print " [3] My first car"
    print " [Q] Quit"
    print "----------------------------------"
    option = getMenuOption(options)
    return option
    
def getWord(prompt):
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        if word.lower() not in swearFilter:
            goodWord = True
        else:
            print "Naughty player...please be polite."
        if not goodWord:
            print "Try again"
    return word
    
def getNumber(prompt, max = "", min = ""):
    num = ""
    goodNum = False
    while not goodNum:
        isNum = True
        num = raw_input(prompt)
        for character in num:
            if character not in "0123456789":
                isNum = False
        if min != "":
            if isNum:
                if float(num) < min:
                    isNum = False
        if max != "":
            if isNum:
                if float(num) > max:
                    isNum = False
        if isNum:
            goodNum = True
        else:
            print "Not a valid number, try again."
    return num
        
def story1():
    place1 = getWord("Enter a place: ")
    noun1 = getWord("Enter a noun: ")
    adjective1 = getWord("Enter a adjective: ")
    verb1 = getWord("Enter a verb: ")
    noun2 = getWord("Enter a noun: ")
    noun3 = getWord("Enter a noun: ")
    adjective2 = getWord("Enter a adjective: ")
    noun4 = getWord("Enter a noun: ")
    story = "It was near the end of the day at"
    story += " " + place1 + ", "
    story += "I saw a rain"
    story += " " + noun1 + ", "                                          
    story += "We ran really"
    story += " " + adjective1 + ","
    story += "Once we got home, we played"
    story += " " + verb1 + ","
    story += "We got bored so we went in the kitchen to get something to"
    story += " " + noun2 + ","
    story += "After the big meal, we put in a"
    story += " " + noun3 + ","
    story += "The movie was so"
    story += " " + adjective2 + ","
    story += "Then after such a long day we went to"
    story += " " + noun4 + ","
    print story
    
def story2():
    name = getWord("Enter a name: ")
    age = getNumber("Enter a number: ")
    noun1 = getWord("Enter a noun: ")
    verb1 = getWord("Enter a verb: ")
    noun2 = getWord("Enter a noun: ")
    verb2 = getWord("Enter a verb: ")
    noun3 = getWord("Enter a noun; ")
    story = "I got a new pet and I named it"
    story += " " + name + ". "
    story += "I think " + name + " is"
    story += " " + age +  " years old"
    story += "The first week we had the dog, it"
    story += " " + noun1 + " up the sofa "
    story += "I had considering getting another dog, but I'm still not"
    story += " " + verb1 + ". "
    story +=  name + " and I have a good"
    story += " " + noun2 + "."
    story += "I wish I had gotten a dog earlier, they are so"
    story += " " + verb2 + "."
    story += "All in all, I would say that having a dog takes a lot of"
    story += " " + noun3 + "."
    print story
   
def story3 ():
    makeandmodel = getWord("Enter a make/model")
    story = "My first car was a"
    story += " " + makeandmodel + "."
    story = "
    print story
    
    
    
def run():
    displayStartScreen()
    choice = ""
    while choice != 'Q':
        choice = menu(3)
        if choice == '1':
            story1()
        elif choice == '2':
            story2()
        elif choice == '3':
            story3 ()
        elif choice == 'Q':
            displayEndScreen()
        else:
            print "Something Awful Occurred...yell at programmer!"
    exit()
run()